package service.calculator.crystalite.laguna;

import java.math.BigDecimal;

import models.Payment;
import models.Rate;
import service.calculator.crystalite.CrystalitePaymentType;
import service.calculator.crystalite.CrystalitePayrollCalculatorImpl;
import util.Rounder;

public class CrystaliteLagunaPayrollCalculatorImpl extends
		CrystalitePayrollCalculatorImpl {

	@Override
	public BigDecimal calculatePayment(Rate rate, Payment payment) {
		BigDecimal paymentCalculation = null;
		CrystalitePaymentType paymentType = CrystalitePaymentType
				.valueOf(payment.paymentType);
		final BigDecimal paymentHrs = BigDecimal.valueOf(payment.hours);

		// 12.50 per day
		final BigDecimal ecolaRate = BigDecimal.valueOf(1.5625);

		// 13.00 per day
		final BigDecimal seaRate = BigDecimal.valueOf(1.625);

		switch (paymentType) {
		case ECOLA:
		case CTPA:
			paymentCalculation = ecolaRate.multiply(paymentHrs);
			paymentCalculation = Rounder.roundup(paymentCalculation);
			break;
		case SEA:
			paymentCalculation = seaRate.multiply(paymentHrs);
			paymentCalculation = Rounder.roundup(paymentCalculation);
			break;
		default:
			paymentCalculation = super.calculatePayment(rate, payment);
		}

		return paymentCalculation;
	}

}
